package com.lancoo.cvas.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lancoo.cvas.aspect.LogAnnotation;
import com.lancoo.cvas.aspect.MessageAnnotation;
import com.lancoo.cvas.entity.*;
import com.lancoo.cvas.exception.BizException;
import com.lancoo.cvas.mapper.CourseMapper;
import com.lancoo.cvas.mapper.RoomMapper;
import com.lancoo.cvas.mapper.TaskInfoMapper;
import com.lancoo.cvas.mapper.TeacherMapper;
import com.lancoo.cvas.pojo.common.*;
import com.lancoo.cvas.pojo.constant.GlobalConstant;
import com.lancoo.cvas.pojo.dto.TaskProcessVo;
import com.lancoo.cvas.pojo.vo.*;
import com.lancoo.cvas.service.*;
import com.lancoo.cvas.util.PagingUtil;
import com.lancoo.cvas.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Api(tags = "通用接口")
@RestController
@RequestMapping("/api/v5.0.1/web/common")
public class CommonController {

    @Resource
    protected HttpServletRequest request;

    @Resource
    private RoomService roomService;

    @Resource
    private TaskInfoService taskInfoService;
    @Resource
    private TaskProcessService taskProcessService;
    @Resource
    private CourseService courseService;
    @Resource
    private MajorService majorService;
    @Resource
    private BasicRuleService basicRuleService;
    @Resource
    private ClassInfoService classInfoService;
    @Resource
    private SegmentService segmentService;
    @Resource
    private AssessmentMethodService assessmentMethodService;
    @Resource
    private TeacherMapper teacherMapper;
    @Resource
    private UserSettingService userSettingService;
    @Resource
    private TaskToGradeService taskToGradeService;
    @Resource
    private TeachingClassWeekService teachingClassWeekService;
    @Resource
    private TeachingClassService teachingClassService;
    @Resource
    private ParameterSettingService parameterSettingService;
    @Resource
    private TeacherService teaherService;
    @Resource
    private RoomMapper roomMapper;
    @Resource
    private TaskInfoMapper taskInfoMapper;
    @Resource
    private CourseMapper courseMapper;


    @ApiOperation("获取校区")
    @GetMapping("/campus/get")
    @LogAnnotation(operationType = "3", operationContent = "获取校区")
    public Result<List<Campus>> getCampusList(@ApiParam(value = "任务流程id", required = true) @RequestHeader(required = false) Integer taskId) {
        if (ObjUtil.isNull(taskId)) {
            return Result.ofSuccess(new ArrayList<>());
        }
        return Result.ofSuccess(roomService.getCampusList(taskId));
    }


    @ApiOperation("开启新学期计划")
    @PostMapping("/addTask")
    @LogAnnotation(operationType = "1", entityName = "taskInput", fieldName = "taskName", operationContent = "开启新学期排课计划")
    public Result<TaskInfo> createTask(@ApiParam(value = "任务", required = true) @RequestBody TaskInput taskInput) {
        return Result.ofSuccess(taskInfoService.addTask(taskInput));
    }


    @ApiOperation("开启新学期计划")
    @GetMapping("/checkTaskInfoName")
    @LogAnnotation(operationType = "3", entityName = "taskInput", fieldName = "taskName", operationContent = "检查计划名称")
    public Result<Boolean> checkTaskInfoName(@ApiParam(value = "任务", required = true) @RequestParam String taskInfoName) {


        //获取计划名称
        List<String> taskNameList = taskInfoMapper.getTaskNameList();

        if (taskNameList.contains(taskInfoName)) {
            return Result.ofSuccess(false);
        }

        return Result.ofSuccess(true);
    }



    @ApiOperation("根据id删除计划")
    @PostMapping("/removeTaskByIds")
    @LogAnnotation(operationType = "4", fieldName = "taskIds", operationContent = "删除计划")
    public Result<Object> removeTaskByIds(@ApiParam(value = "任务ids", required = true) @RequestBody List<Integer> taskIds) {
        taskInfoService.removeTaskByIds(taskIds);
        return Result.ofSuccess("删除成功");
    }


    @ApiOperation("获取专业")
    @GetMapping(value = "/getMajor")
    @LogAnnotation(operationType = "3", operationContent = "获取专业")
    public Result<List<MajorDto>> getMajor(@ApiParam(value = "任务流程id", required = true) @RequestHeader(required = false) Integer taskId,
                                           @ApiParam(value = "1教学计划 2课程 3环节 4学生", required = true) @RequestParam Integer module) {

        if (ObjUtil.isNull(taskId)) {
            return Result.ofSuccess(new ArrayList<>());
        }

        return Result.ofSuccess(taskInfoService.getMajorByTaskId(taskId, module));
    }


    @ApiOperation("获取年级")
    @GetMapping(value = "/getGrade")
    @LogAnnotation(operationType = "3", operationContent = "获取年级")
    public Result<List<GradeDto>> getGrade(@ApiParam(value = "任务流程id", required = true) @RequestHeader(required = false) Integer taskId,
                                           @ApiParam(value = "1教学计划 2课程 3环节 4学生", required = true) @RequestParam Integer module) {

        if (ObjUtil.isNull(taskId)) {
            return Result.ofSuccess(new ArrayList<>());
        }
        return Result.ofSuccess(taskInfoService.getGradeByTaskId(taskId, module));
    }


    @ApiOperation("开启任务时获取年级信息")
    @GetMapping(value = "/getGradeOnTask")
    @LogAnnotation(operationType = "3", operationContent = "开启任务时获取年级信息")
    public Result<List<GradeDto>> getGrade(@ApiParam(value = "学校id", required = true) @RequestParam String schoolId,
                                           @ApiParam(value = "学期id", required = true) @RequestParam String term) {
        return Result.ofSuccess(taskInfoService.getGrade(schoolId, term));
    }


    @ApiOperation("获取全部计划")
    @GetMapping("/getTaskList")
    @LogAnnotation(operationType = "3", operationContent = "获取全部计划")
    public Result<PageInfo<TaskInfo>> getTaskList(@ApiParam(value = "学校id", required = true) @RequestParam String schoolId,
                                                  @ApiParam(value = "页码", required = true) @RequestParam Integer currentPage,
                                                  @ApiParam(value = "页容", required = true) @RequestParam Integer pageSize) {
        //deleted为0 表示未删除
        LambdaQueryWrapper<TaskInfo> queryWrapper = new LambdaQueryWrapper<TaskInfo>()
                .eq(TaskInfo::getSchoolId, schoolId).eq(TaskInfo::getDeleted, Deleted.NOT.getCode());
        List<TaskInfo> taskList = taskInfoService.list(queryWrapper);
        List<TaskInfo> sortTask = taskList.stream().sorted(Comparator.comparing(TaskInfo::getTaskId).reversed()).collect(Collectors.toList());
        PageInfo<TaskInfo> pageTask = PagingUtil.getPages(currentPage, pageSize, sortTask);
        return Result.ofSuccess(pageTask);
    }


    @ApiOperation("修改任务阶段状态")
    @GetMapping(value = "/taskProgress/update")
    @LogAnnotation(operationType = "2", operationContent = "修改任务阶段状态")
    @MessageAnnotation(operationType = "2", operationContent = "修改任务阶段状态")
    public Result<Boolean> updateTaskProgress(@ApiParam(value = "任务流程id", required = true) TaskProcessVo processVo) {


        return Result.ofSuccess(taskProcessService.updateProcess(Integer.valueOf(request.getHeader("taskId")), processVo.getId(), processVo.getFinish()));
    }


    @ApiOperation("获取单个过程状态")
    @GetMapping(value = "/getTaskProgressById")
    @LogAnnotation(operationType = "3", operationContent = "获取单个过程状态")
    public Result<TaskProcess> getTaskProgressById(@ApiParam(value = "任务Id", required = true) @RequestHeader Integer taskId,
                                                   @ApiParam(value = "任务流程id", required = true) @RequestParam Integer id) {


        return Result.ofSuccess(taskProcessService.getTaskProgressById(taskId, id));
    }


    @ApiOperation("获取任务各阶段状态")
    @GetMapping(value = "/taskProgress")
    @LogAnnotation(operationType = "3", operationContent = "获取任务各阶段状态")
    public Result<List<TaskProcess>> getTaskProgress(@ApiParam(value = "任务Id", required = true) @RequestHeader Integer taskId) {
        return Result.ofSuccess(taskProcessService.getProcessList(taskId));
    }

    @GetMapping("/getRoomList")
    @ApiOperation("获取教室")
    @LogAnnotation(operationType = "3", operationContent = "获取教室")
    public Result<List<Room>> getRoomList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                          @ApiParam(value = "学校id ", required = false) @RequestParam String schoolId,
                                          @ApiParam(value = "教室类型 ", required = false) @RequestParam(required = false) Integer roomType,
                                          @ApiParam(value = "校区id", required = true) @RequestParam String campusId,
                                          @ApiParam(value = "学期", required = true) @RequestParam String term) {
        return Result.ofSuccess(roomService.getRomList(taskId, schoolId, roomType, campusId, term));
    }

    @GetMapping("/getSubRoomList")
    @ApiOperation("获取拆班教室")
    @LogAnnotation(operationType = "3", operationContent = "获取拆班教室")
    public Result<List<Room>> getSubRoomList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                             @ApiParam(value = "校区id", required = true) @RequestParam String subId) {
        return Result.ofSuccess(roomService.getSubRoomList(taskId, subId));
    }

    @GetMapping("/getSubTeacherList")
    @ApiOperation("获取拆班教师")
    @LogAnnotation(operationType = "3", operationContent = "获取拆班教师")
    public Result<List<Teacher>> getSubTeacherList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                   @ApiParam(value = "校区id", required = true) @RequestParam String subId) {
        return Result.ofSuccess(teaherService.getSubTeacherList(taskId, subId));
    }


    @GetMapping("/getRoomTree")
    @ApiOperation("获取教室树")
    @LogAnnotation(operationType = "3", operationContent = "获取教室树")
    public Result<List<RoomVo>> getRoomTree(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                            @ApiParam(value = "学校Id", required = true) @RequestParam String schoolId,
                                            @ApiParam(value = "学期", required = true) @RequestParam String term,
                                            @ApiParam(value = "1 规则， 2 课表", required = true) @RequestParam Integer module) {
        return Result.ofSuccess(roomService.getRoomTree(taskId, schoolId, term, module));
    }

    @GetMapping("/getClassVo")
    @ApiOperation("通过年级id和专业id获取班级信息")
    @LogAnnotation(operationType = "3", operationContent = "通过年级id和专业id获取班级信息")
    public Result<List<ClassVo>> getClassVo(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                            @ApiParam(value = "年级id ", required = true) @RequestParam(required = false) String gradeId,
                                            @ApiParam(value = "专业id", required = true) @RequestParam Long majorId) {
        return Result.ofSuccess(basicRuleService.getClassVo(taskId, gradeId, majorId));
    }


    @GetMapping("/getCourseList")
    @ApiOperation("获取所有课程")
    @LogAnnotation(operationType = "3", operationContent = "获取所有课程")
    public Result<List<Course>> getCourseList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId) {
        List<Course> courseList = courseMapper.getCourseList(taskId);
        if(CollUtil.isNotEmpty(courseList)){
            courseList =courseList.stream().sorted(Comparator.comparing(Course::getCourseName)).collect(Collectors.toList());

        }
        return Result.ofSuccess(courseList);
    }



    @GetMapping("/getClassTree")
    @ApiOperation("获取行政班树")
    @LogAnnotation(operationType = "3", operationContent = "获取行政班树")
    public Result<List<ClassTree>> getClassTree(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                @ApiParam(value = "1 规则， 2 课表", required = true) @RequestParam Integer module) {
        return Result.ofSuccess(classInfoService.getClassTree(taskId, module));
    }


    @GetMapping("/getBuildingList")
    @ApiOperation("获取楼宇")
    @LogAnnotation(operationType = "3", operationContent = "获取楼宇")
    public Result<List<Room>> getBuildingList(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                              @ApiParam(value = "学校", required = true) @RequestParam String schoolId,
                                              @ApiParam(value = "学期", required = true) @RequestParam String term,
                                              @ApiParam(value = "校区id", required = false) @RequestParam(required = false) String campusId,
                                              @ApiParam(value = "模块", required = false) @RequestParam(required = false) Integer module) {
        return Result.ofSuccess(roomService.getBuildingList(taskId, schoolId, term, campusId, module));
    }

    @GetMapping("/getRoomListByBuilding")
    @ApiOperation("获取教室")
    @LogAnnotation(operationType = "3", operationContent = "获取教室")
    public Result<List<Room>> getRoomListByBuilding(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                    @ApiParam(value = "楼宇id", required = false) @RequestParam(required = false) Integer buildingId,
                                                    @ApiParam(value = "学校", required = true) @RequestParam String schoolId,
                                                    @ApiParam(value = "学期", required = true) @RequestParam String term,
                                                    @ApiParam(value = "校区id", required = true) @RequestParam String campusId) {
        return Result.ofSuccess(roomService.getRoomListByBuilding(taskId, campusId, buildingId, schoolId, term));
    }


    @ApiOperation("获取考核方式")
    @GetMapping(value = "/getAssessmentMethod")
    @LogAnnotation(operationType = "3", operationContent = "获取考核方式")
    public Result<List<AssessmentMethod>> getAssessmentMethod(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                              @ApiParam(value = "学校id", required = true) @RequestParam String schoolId,
                                                              @ApiParam(value = "1课程  2环节", required = true) @RequestParam Integer flag) {
        //先查询是否是否有考核方式
        List<AssessmentMethod> list = assessmentMethodService.lambdaQuery().eq(AssessmentMethod::getTaskId, taskId).eq(AssessmentMethod::getFlag, flag).eq(AssessmentMethod::getSchoolId, schoolId).list();
        //插入为空则插入默认值
        if (list.size() == 0) {
            list.add(new AssessmentMethod().setTaskId(taskId).setFlag(flag).setSchoolId(schoolId).setAssessmentName("考试"));
            list.add(new AssessmentMethod().setTaskId(taskId).setFlag(flag).setSchoolId(schoolId).setAssessmentName("考查"));
            assessmentMethodService.saveBatch(list);
        }
        return Result.ofSuccess(list);
    }

    @ApiOperation("添加考核方式")
    @PostMapping(value = "/addAssessmentMethod")
    @LogAnnotation(operationType = "1", operationContent = "添加考核方式")
    public Result<AssessmentMethod> addAssessmentMethod(@ApiParam(value = "考核方式实体类", required = true) @RequestBody AssessmentMethod assessmentMethod) {

        List<AssessmentMethod> list = assessmentMethodService.lambdaQuery().eq(AssessmentMethod::getTaskId, assessmentMethod.getTaskId()).eq(AssessmentMethod::getSchoolId, assessmentMethod.getSchoolId()).list();

        if (CollUtil.isNotEmpty(list)) {
            List<String> collect = list.stream().map(AssessmentMethod::getAssessmentName).collect(Collectors.toList());
            if (collect.contains(assessmentMethod.getAssessmentName())) {
                return Result.ofFail(assessmentMethod.getAssessmentName() + "该考核方式已经存在");
            }

            if(StringUtils.isBlank(assessmentMethod.getAssessmentName())){
                return Result.ofFail("考核方式的名称不可以为空");
            }
        }

        assessmentMethodService.save(assessmentMethod);
        return Result.ofSuccess(assessmentMethod);
    }


    @ApiOperation("删除考核方式")
    @GetMapping(value = "/deleteAssessmentMethod")
    @LogAnnotation(operationType = "4", operationContent = "删除考核方式")
    public Result<String> deleteAssessmentMethod(@ApiParam(value = "考核方式实体类", required = true) @RequestHeader Integer taskId,
                                                 @ApiParam(value = "考核方式实体类", required = true) @RequestParam Long assessmentMethodId) {
        assessmentMethodService.lambdaUpdate().eq(AssessmentMethod::getTaskId, taskId).eq(AssessmentMethod::getAssessmentId, assessmentMethodId).remove();

        List<TeachingClass> list = teachingClassService.lambdaQuery().eq(TeachingClass::getTaskId, taskId).eq(TeachingClass::getDeleted, Deleted.NOT.getCode()).list();
        if (CollUtil.isNotEmpty(list)) {
            List<Long> collect = list.stream().map(TeachingClass::getTeachingClassId).collect(Collectors.toList());

            teachingClassWeekService.lambdaUpdate().in(TeachingClassWeek::getTeachingClassId, collect).eq(TeachingClassWeek::getAssessmentId, assessmentMethodId).set(TeachingClassWeek::getAssessmentId, null)
                    .set(TeachingClassWeek::getAssessmentName, null).update();
            parameterSettingService.lambdaUpdate().eq(ParameterSetting::getTaskId, taskId)
                    .eq(ParameterSetting::getAssessmentMethodId, assessmentMethodId).set(ParameterSetting::getAssessmentMethodId, null)
                    .set(ParameterSetting::getAssessmentMethod, null).update();
        }
        return Result.ofSuccess("考核方式删除成功");
    }


    @ApiOperation("获取周次信息")
    @GetMapping(value = "/week/{taskId}")
    @LogAnnotation(operationType = "3", operationContent = "获取周次信息")
    public Result<WeekDateVo> countWeek(@ApiParam(value = "任务Id", required = true) @PathVariable Integer taskId) {
        return Result.ofSuccess(taskInfoService.countWeek(taskId));
    }


    @ApiOperation("获取教师列表")
    @GetMapping(value = "/getTeacherList")
    @LogAnnotation(operationType = "3", operationContent = "获取教师列表")
    public Result<List<Teacher>> getTeacherList(@ApiParam(value = "任务Id", required = true) @RequestHeader Integer taskId) {

        TaskInfo taskInfo = taskInfoService.getById(taskId);
        List<Teacher> teacherList = teacherMapper.selectList(new LambdaQueryWrapper<Teacher>()
                .eq(Teacher::getSchoolId, taskInfo.getSchoolId())
                .eq(Teacher::getTerm, taskInfo.getTerm()).eq(Teacher::getDeleted, Deleted.NOT.getCode()));
        return Result.ofSuccess(teacherList);
    }


    @ApiOperation("获取场地类型")
    @GetMapping(value = "/getRoomType")
    @LogAnnotation(operationType = "3", operationContent = "获取场地类型")
    public Result<List<RoomTypeDto>> getRoomType(@ApiParam(value = "任务Id", required = true) @RequestHeader Integer taskId) {

        TaskInfo taskInfo = taskInfoService.getById(taskId);
        List<Room> roomList = roomService.lambdaQuery().eq(Room::getSchoolId, taskInfo.getSchoolId())
                .eq(Room::getTerm, taskInfo.getTerm())
                .eq(Room::getDeleted, Deleted.NOT.getCode()).list();

        List<Integer> roomTypeId = roomList.stream().map(Room::getRoomType).distinct().collect(Collectors.toList());
        List<RoomTypeDto> roomTypeDtoList = new ArrayList<>();

        roomTypeId.forEach(o -> {
            RoomTypeDto roomTypeDto = new RoomTypeDto();
            roomTypeDto.setRoomTypeId(o);
            roomTypeDto.setRoomTypeName(GlobalConstant.roomTypeMap.get(o));
            roomTypeDtoList.add(roomTypeDto);
        });

        return Result.ofSuccess(roomTypeDtoList);


    }


    @ApiOperation("获取场地分组")
    @GetMapping(value = "/getRoomGroup")
    @LogAnnotation(operationType = "3", operationContent = "获取场地分组")
    public Result<List<RoomGroup>> getRoomGroup(@ApiParam(value = "任务Id", required = true) @RequestHeader Integer taskId) {

        TaskInfo taskInfo = taskInfoService.getById(taskId);

        List<Room> roomList = roomService.lambdaQuery().eq(Room::getSchoolId, taskInfo.getSchoolId())
                .eq(Room::getTerm, taskInfo.getTerm())
                .eq(Room::getDeleted, Deleted.NOT.getCode()).list();

        List<TaskInfo> taskInfoList = taskInfoService.lambdaQuery().eq(TaskInfo::getSchoolId, taskInfo.getSchoolId())
                .eq(TaskInfo::getTerm, taskInfo.getTerm()).list();

        taskInfoList.remove(taskInfo);

        if (CollUtil.isNotEmpty(taskInfoList)) {

            List<Integer> collect = taskInfoList.stream().map(TaskInfo::getTaskId).distinct().collect(Collectors.toList());
            List<Long> collect1 = classInfoService.lambdaQuery().in(ClassInfo::getTaskId, collect).list().stream().map(ClassInfo::getRoomId).distinct().collect(Collectors.toList());
            if (CollUtil.isNotEmpty(collect1)) {
                roomList = roomList.stream().filter(p -> !collect1.contains(p.getRoomId())).collect(Collectors.toList());
            }
        }


        List<RoomGroup> roomTypeDtoList = new ArrayList<>();


        List<RoomDto> roomDtos = roomMapper.getRoomWithClassInfo(taskInfo.getSchoolId(), taskInfo.getTerm(), null);


        List<RoomDto> collect = roomDtos.stream().filter(p -> ObjUtil.isEmpty(p.getTaskId()) || p.getTaskId().equals(taskId)).collect(Collectors.toList());

        Map<Integer, List<Room>> collect1 = roomList.stream().collect(Collectors.groupingBy(Room::getRoomType));

        collect1.forEach((key, value) -> {
            List<Long> collect2 = value.stream().map(Room::getRoomId).distinct().collect(Collectors.toList());
            List<RoomDto> collect3 = collect.stream().filter(p -> collect2.contains(p.getRoomId())).distinct().collect(Collectors.toList());
            RoomGroup roomGroup = new RoomGroup();
            roomGroup.setRoomTypeId(key);
            roomGroup.setRoomType(GlobalConstant.roomTypeMap.get(key));
            roomGroup.setRoomList(collect3);
            roomTypeDtoList.add(roomGroup);
        });


        return Result.ofSuccess(roomTypeDtoList);

    }


    @ApiOperation("获取用户配置")
    @GetMapping(value = "/getSidebar")
    @LogAnnotation(operationType = "3", operationContent = "获取用户配置")
    public Result<UserSetting> getUserSetting(@ApiParam(value = "用户id", required = true) @RequestHeader String userId) {
        UserSetting userSetting = userSettingService.getUserSettingByUserId(userId);
        return Result.ofSuccess(userSetting);
    }


    @ApiOperation("获取任务信息")
    @GetMapping(value = "/getTaskInfo")
    @LogAnnotation(operationType = "3", operationContent = "获取任务信息")
    public Result<TaskInfoDto> getUserSetting(@ApiParam(value = "任务id", required = true) @RequestParam Integer taskId) {
        TaskInfoDto taskInfoDto = new TaskInfoDto();
        TaskInfo taskInfo = taskInfoService.getById(taskId);

        List<TaskToGrade> list = taskToGradeService.lambdaQuery().eq(TaskToGrade::getTaskId, taskId).list();

        List<GradeDto> gradeDtos = new ArrayList<>();

        list.forEach(o -> {
            GradeDto gradeDto = new GradeDto();

            gradeDto.setGradeId(o.getGradeId());
            gradeDto.setGradeName(o.getGradeName());
            gradeDtos.add(gradeDto);
        });
        taskInfoDto.setTaskInfo(taskInfo);
        taskInfoDto.setGradeDtos(gradeDtos);


        return Result.ofSuccess(taskInfoDto);
    }


    @ApiOperation("设置用户侧边栏配置")
    @PostMapping(value = "/setSidebar")
    @LogAnnotation(operationType = "2", operationContent = "设置用户侧边栏配置")
    public Result<Boolean> addOrUpdateSetting(@ApiParam(value = "用户配置类", required = true) @RequestBody UserSetting userSetting) {
        return Result.ofSuccess(userSettingService.updateUserSetting(userSetting));
    }



    //=======================全校课表筛选项===========================
    @GetMapping("/getAllClass")
    @ApiOperation("获取行政班")
    @LogAnnotation(operationType = "3", operationContent = "获取行政班")
    public Result<List<ClassInfo>> getAllClass(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                @ApiParam(value = "年级id", required = false) @RequestParam(required = false) String gradeId) {
        return Result.ofSuccess(classInfoService.getAllClass(taskId, gradeId));
    }

    @GetMapping("/getAllCourse")
    @ApiOperation("获取课程")
    @LogAnnotation(operationType = "3", operationContent = "获取课程")
    public Result<List<Course>> getAllCourse(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId) {
        return Result.ofSuccess(courseService.getAllCourse(taskId));
    }

}
